<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" id="viewport" content="width=device-width, initial-scale=1">
    <title>登录页面</title>
<!--    <link rel="stylesheet" href="https://unpkg.com/mint-ui/lib/style.css">-->
<!--    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>-->
<!--    <script src="https://unpkg.com/mint-ui/lib/index.js"></script>-->
<!--    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>-->
<!--    <script src="https://cdn.bootcss.com/qs/6.5.1/qs.min.js"></script>-->
    <link rel="stylesheet" th:href="@{/index/common/style.css}">
    <script th:src="@{/index/common/vue.js}"></script>
    <script th:src="@{/index/common/index.js}"></script>
    <script th:src="@{/index/common/axios.min.js}"></script>
    <script th:src="@{/index/common/qs.min.js}"></script>
    <link th:href="@{/index/css/reset.css}" rel="stylesheet">
    <link th:href="@{/index/css/main.css?ver=1.0}" rel="stylesheet">
</head>
<body>
    <div id="applogin" class="login">
        <div class="title">医院工作人员</br>班车预约</div>
        <div class="username"><mt-field placeholder="请输入姓名" v-model="name" style="text-align: center"></mt-field></div>
        <div class="username"><mt-field placeholder="请输入手机号" v-model="shoujihao"></mt-field></div>
        <div class="btn"><mt-button @click.native="handleClick">登录</mt-button></div>
        <div class="clearfix">
            <div class="fl clearfix">
                <div class="fl rember"><mt-switch v-model="rememberPsw"></mt-switch></div>
                <div class="fl regist">记住账号</div>
            </div>
        </div>
    </div>
    <script>

        const qs = Qs;
        const vm = new Vue({
            el: '#applogin',
            data: {
                message: 'hello',
                name: '',
                shoujihao: '',
                rememberPsw: false,
                sfz: '',
                mim: '',
                ifr: Boolean
            },
            created: function () {
                if (this.name) {
                    this.remberPassword = true
                }
            },
            mounted() {
                console.log(localStorage.getItem('name'))
                console.log(localStorage.getItem('phone'))
                console.log(localStorage.getItem('ifr'))
                if (localStorage.getItem('ifr')) {
                    this.name = localStorage.getItem('name')
                    this.shoujihao = localStorage.getItem('phone')
                    this.rememberPsw = true
                }
            },
            methods: {
                handleClick:function (event) {
                    if (this.name === '') {
                        this.$toast('请输入姓名！')
                    } else if (this.shoujihao === '') {
                        this.$toast('请填写手机号！')
                    } else {
                        axios.post('/system/yuyue/login', qs.stringify({'name':this.name, 'shoujihao': this.shoujihao})).then(res => {
                            window.localStorage.setItem(
                                "userfindid",
                                this.name
                            );
                            if (res.data.code === 0) {
                                if (this.rememberPsw) {
                                    window.localStorage.setItem(
                                        "name",
                                        this.name
                                    );
                                    window.localStorage.setItem(
                                        "phone",
                                        this.shoujihao
                                    );
                                    window.localStorage.setItem(
                                        "ifr",
                                        this.rememberPsw
                                    );
                                } else {
                                    localStorage.removeItem("name");
                                    localStorage.removeItem("phone");
                                    localStorage.removeItem("ifr");
                                }
                                location.href = '../yuyue/index';
                            } else if (res.data.code === 500) {
                                this.$toast(res.data.msg);
                            }
                        });
                    }
                },
            }

        })
    </script>
</body>
</html>